<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Goods extends Model
{
    protected $fillable = ['name','image','introduction','price','game_images'];
    protected $attributes = ['game_images'=>'array'];

    public static function boot()
    {
        parent::boot();
        self::creating(function (Goods $goods){
            $goods->uid = \Auth::id();
        });
    }

    public function getGameImagesAttribute($key)
    {
        return explode(',',$key);
    }
}
